const mongoose = require('mongoose');
const { ObjectId } = mongoose.Schema;

const locationSchema = mongoose.Schema({
  line: Number,
  column: Number,
}, { _id: false });
/**
 * Export model definition object.
 */
module.exports = {
  creatorId: ObjectId,
  projectId: ObjectId,
  versionId: { type: ObjectId, index: true },
  fileId: { type: ObjectId, index: true },
  function: String,
  // DD(两次变量定义之间没有被使用), DU(变量定义了但在其作用域中没有使用）, UR（变量未定义就引用，未初始化）
  // RO(只引用) DO(只定义) DR(既定义也使用)
  // R(引用) D(定义) E(声明) I(作为输入) O(作为输出)
  check: {
    type: String,
    eumn: ['DD', 'DU', 'UR', 'DO', 'RO', 'DR', 'D', 'E', 'R', 'I', 'O'],
  },
  // L(局部变量) G(全局变量) P(参数) LG(局部全局变量)
  kind: {
    type: String,
    eumn: ['L', 'G', 'P', 'LG'],
  },
  var: String,
  message: String,
  file: String,
  range: {
    begin: locationSchema,
    end: locationSchema,
  },
};
